function ajax(url, resolve, reject) {
	let xhr;
	if (window.XMLHttpRequest) {
		xhr = new XMLHttpRequest();
	} else {
		xhr = new ActiveXObject('Microsoft.XMLHTTP');
	}
	xhr.open('GET', url);
	try {
		xhr.send();
		resolve(xhr.response);
	} catch (error) {
		reject(error);
	}
}

let promise = new Promise((resolve, reject) => {
	ajax(url,
		(data) => { resolve(data) },
		(error) => { reject(error) }
	)
})

promise.then((data) => {
	console.log(data);
	return '100'
},
	(reason) => { console.log(reason); }
).then((data) => { console.log(data); }, null);

const p1 = Promise.resolve(100);
const p2 = Promise.reject('error');
p1.then(console.log);
p2.catch(console.log);

let p = Promise.all([p1, p2]);
p.then(console.log);
p.finally(console.log);
p = Promise.race([p1, p2]);
p.then(console.log);
